/*
	Creates Figure 1
*/

// SET DIRECTORIES
cd ""

	use data_study1.dta, clear
	
	
	gen east = cntry_china == 1 | cntry_korea == 1 | cntry_japan == 1


	d rate_*, varlist
	foreach v in `r(varlist)' {
		loc n = subinstr("`v'", "rate_", "", .)
		gen rate_as_`n' = `v' if race == "Asian"
		//gen rate_ot_`n' = `v' if race != "Asian"
		gen sd_as_`n' = rate_as_`n'
		//gen sd_ot_`n' = rate_ot_`n'
	}

	
	// Limit to control units
	keep if inlist(treatment, "control", "duck2")
	replace rate_harris = . if treatment == "control"
	replace rate_duck = . if treatment == "duck2"
	loc note = "Means are based on responses from Control conditions."
	loc note2 = "(Asian Respondents: N = `aN')"
	

	collapse (mean) rate_as* (sem) sd_* 

	gen i = .
	reshape long rate_as_ sd_as_, i(i) j(group) s
	drop i
	replace group = proper(group)
	gen upper_as =  rate_as + 1.96*sd_as
	gen lower_as = rate_as - 1.96*sd_as
 

	// Groups		
	drop if inlist(group, "Harris", "Duckworth") // Keep country ratings
	gsort -rate_as
	gen order = _n	
	replace order = order*2

	gen order2 = order+1

	labmask order, values(group)
	labmask order2, values(group)


	// greyscale vers
	graph tw (bar rate_as order, barw(1) bc(gs6)) ///
		(rcap upper_as lower_as order, lc(gs4) lw(med)), ///
		legend(off) ///
		xtitle("") xlabel(2(2)38, valuelabel labsize(small) angle(45)) ylabel(0(0.25)1) xline(31, lc(black)) ///
		subtitle("How representative of Asians as a whole do you perceive the following groups to be? (5 pt scale)", size(small))

	graph export Figure1.png, as(png) replace
	
